package com.mp.goods.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.mp.goods.bean.StdValue;
import com.mp.goods.dto.InsertStdValueDTO;
import com.mp.goods.mapper.StdValueMapper;
import com.mp.goods.service.StdValueService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 规格值表 服务实现类
 * </p>
 *
 * @author notejava
 * @since 2020-07-11
 */
@Service
public class StdValueServiceImpl extends ServiceImpl<StdValueMapper, StdValue> implements StdValueService {

    @Override
    public Boolean insert(List<InsertStdValueDTO> model) {
        List<StdValue> stdValues= new ArrayList<>();
        for (InsertStdValueDTO insertStdValueDTO : model) {
            StdValue stdValue = new StdValue();
            BeanUtil.copyProperties(insertStdValueDTO,stdValue);
            stdValues.add(stdValue);
        }
        return this.saveBatch(stdValues);
    }
}
